<template>
  <div>
    <el-dialog class="app-container" title="title" width="800px" :visible.sync="visible" top="5vh" append-to-body>
      <el-table  :data="stockList" ref="select" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="物品名称" align="center" prop="productName" />
        <el-table-column label="物品类型" align="center" prop="productType" />
        <el-table-column label="库存" align="center" prop="quantity" />
        <el-table-column label="仓库名称" align="center" prop="warehouseName" />
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>

    </el-dialog>
  </div>

</template>

<script>
import {listStock} from '@/api/module/stock'
export default {
  name: "product",
  data(){
    return{
      visible:false,
      stockList:[],
      productList:[],//产品列表
    }
  },
  created() {
    this.initData()
  },
  methods:{
    show(){
      this.visible = true;
    },
    initData(){
      listStock().then(response=>{
        console.log(response)
        this.stockList=response.rows
      })
    },
    handleSelectionChange(value){
      this.productList=value
    },
    submitForm(){
      this.visible=false
      this.$emit('showProduct',this.productList)
      this.$refs.select.clearSelection()

    },
    cancel(){
      this.productList=[]
      this.$refs.select.clearSelection()
      this.visible=false
    }
  }
}
</script>

<style scoped>

</style>
